package com.vcar.LDiceClient.chat
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.system.ApplicationDomain;
	import flash.utils.getDefinitionByName;

	public class ChatSmileObject extends ChatExObject
	{
		public var smileId:int;
		public var smileName:String;
		private var em:Sprite;
		private var smileList:Array=[];
		public function ChatSmileObject(arg:String)
		{
			smileId=int(arg);
			try{
				smileName=smileList[smileId];	
			}catch(e:Error){
				throw new Error("undefined smile");
			}
					
			if(ApplicationDomain.currentDomain.hasDefinition(smileName)){
				switch(smileName){
//					case "em_0":
//						em = new em_1();
//						break;
				}
				addChild(em);				
				em.addEventListener(MouseEvent.CLICK,onClick);
				useHandCursor=true;
				buttonMode=true;				
			}else{
				throw new Error("undefined smile");
			}
		}
		
		private function onClick(e:MouseEvent):void
		{
			var evt:ChatExObjectEvent=new ChatExObjectEvent(ChatExObjectEvent.CLICK);
				evt.data=smileName;
				evt.exObject=this;
				evt.targetType="SmileObject";
			dispatchEvent(evt);
		}
	}
}